package com.demo2do.fms.entity.data.cost;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;

import com.demo2do.core.format.PersistentFormat;
import com.demo2do.fms.entity.authority.Organization;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 司机工资
 * 
 * @author Chang Liu
 * 
 */
@Entity
@Table(name = "TBL_TRUCK_DRIVER_SALARY")
public class DriverSalary {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    /** 驾驶员人数 */
    private Integer driverCount;

    /** 主驾重载工资 */
    private BigDecimal mainDriverFullSalary;
    
    /** 第一副驾重载工资 */
    private BigDecimal firstViceDriverFullSalary;
    
    /** 主驾空载工资 */
    private BigDecimal mainDriverEmptySalary;
    
    /** 第一副驾空载工资 */
    private BigDecimal firstViceDriverEmptySalary;
    
    /** 所属公司 */
    @ManyToOne(fetch = FetchType.LAZY, optional = true)
    @JoinColumn(name = "organization_id", referencedColumnName = "id")
    @JsonIgnore(value = true)
    @PersistentFormat
    private Organization organization;
    
    /** 创建人  */
    private Long creatorId;
    
    /** 创建时间  */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDate;
    
    /** 开始时间  */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startDate;
    
    /** 结束时间  */
    private Date endDate;
    
    @Column(name = "is_disabled")
    private Boolean disabled;
    
    /**
     *  
     * @param organization
     * @param driverCount
     * @param mainDriverFullSalary
     * @param mainDriverEmptySalary
     */
     public DriverSalary(Organization organization , Integer driverCount ,BigDecimal mainDriverFullSalary,BigDecimal mainDriverEmptySalary){
         this.organization = organization;
         this.driverCount = driverCount;
         this.mainDriverFullSalary = mainDriverFullSalary;
         this.mainDriverEmptySalary = mainDriverEmptySalary;
         
     }
     
    /**
     * @param organization
     * @param driverCount
     * @param mainDriverFullSalary
     * @param mainDriverEmptySalary
     * @param firstViceDriverFullSalary
     * @param firstViceDriverEmptySalary
     */
    public DriverSalary(Organization organization , Integer driverCount ,BigDecimal mainDriverFullSalary,BigDecimal mainDriverEmptySalary,
                        BigDecimal firstViceDriverFullSalary ,BigDecimal firstViceDriverEmptySalary){
        this.organization = organization;
        this.driverCount = driverCount;
        this.mainDriverFullSalary = mainDriverFullSalary;
        this.mainDriverEmptySalary = mainDriverEmptySalary;
        this.firstViceDriverFullSalary = firstViceDriverFullSalary;
        this.firstViceDriverEmptySalary = firstViceDriverEmptySalary;
        
    }
    
    /**
     * 
     * @param operator
     * @return
     */
    public DriverSalary operator(Long operator){
        this.creatorId = operator;
        return this;
    }
    
    /**
     * @return
     */
    public DriverSalary disable(){
        
        this.disabled = true;
        this.endDate = new Date();
        
        return this;
    }
    
    /**
     * 
     * @return
     */
    public DriverSalary init(){
        
        this.createDate=new Date();
        this.startDate = new Date();
        this.disabled=false;
        return this;
        
    }
    
    /**
     * 
     */
    public DriverSalary (){
        
    }
    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the driverCount
     */
    public Integer getDriverCount() {
        return driverCount;
    }

    /**
     * @return the mainDriverFullSalary
     */
    public BigDecimal getMainDriverFullSalary() {
        return mainDriverFullSalary;
    }

    /**
     * @return the firstViceDriverFullSalary
     */
    public BigDecimal getFirstViceDriverFullSalary() {
        return firstViceDriverFullSalary;
    }

    /**
     * @return the mainDriverEmptySalary
     */
    public BigDecimal getMainDriverEmptySalary() {
        return mainDriverEmptySalary;
    }

    /**
     * @return the firstViceDriverEmptySalary
     */
    public BigDecimal getFirstViceDriverEmptySalary() {
        return firstViceDriverEmptySalary;
    }

    /**
     * @return the organization
     */
    public Organization getOrganization() {
        return organization;
    }

    /**
     * @return the creatorId
     */
    public Long getCreatorId() {
        return creatorId;
    }

    /**
     * @return the createDate
     */
    public Date getCreateDate() {
        return createDate;
    }

    /**
     * @return the startDate
     */
    public Date getStartDate() {
        return startDate;
    }

    /**
     * @return the endDate
     */
    public Date getEndDate() {
        return endDate;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param driverCount the driverCount to set
     */
    public void setDriverCount(Integer driverCount) {
        this.driverCount = driverCount;
    }

    /**
     * @param mainDriverFullSalary the mainDriverFullSalary to set
     */
    public void setMainDriverFullSalary(BigDecimal mainDriverFullSalary) {
        this.mainDriverFullSalary = mainDriverFullSalary;
    }

    /**
     * @param firstViceDriverFullSalary the firstViceDriverFullSalary to set
     */
    public void setFirstViceDriverFullSalary(BigDecimal firstViceDriverFullSalary) {
        this.firstViceDriverFullSalary = firstViceDriverFullSalary;
    }

    /**
     * @param mainDriverEmptySalary the mainDriverEmptySalary to set
     */
    public void setMainDriverEmptySalary(BigDecimal mainDriverEmptySalary) {
        this.mainDriverEmptySalary = mainDriverEmptySalary;
    }

    /**
     * @param firstViceDriverEmptySalary the firstViceDriverEmptySalary to set
     */
    public void setFirstViceDriverEmptySalary(BigDecimal firstViceDriverEmptySalary) {
        this.firstViceDriverEmptySalary = firstViceDriverEmptySalary;
    }

    /**
     * @param organization the organization to set
     */
    public void setOrganization(Organization organization) {
        this.organization = organization;
    }
    
    /**
     * @param creatorId the creatorId to set
     */
    public void setCreatorId(Long creatorId) {
        this.creatorId = creatorId;
    }

    /**
     * @param createDate the createDate to set
     */
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    /**
     * @param startDate the startDate to set
     */
    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    /**
     * @param endDate the endDate to set
     */
    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }
}
